package com.baidu.mapapi;

import android.os.Bundle;
import android.util.Log;
import java.io.UnsupportedEncodingException;

public class MKSearch
{
  public static final int EBUS_NO_SUBWAY = 6;
  public static final int EBUS_TIME_FIRST = 3;
  public static final int EBUS_TRANSFER_FIRST = 4;
  public static final int EBUS_WALK_FIRST = 5;
  public static final int ECAR_DIS_FIRST = 1;
  public static final int ECAR_FEE_FIRST = 2;
  public static final int ECAR_TIME_FIRST = 0;
  public static final int TYPE_AREA_MULTI_POI_LIST = 45;
  public static final int TYPE_AREA_POI_LIST = 21;
  public static final int TYPE_CITY_LIST = 7;
  public static final int TYPE_POI_LIST = 11;
  private static int b = 10;
  private Bundle a = null;
  private int c = 3;
  private int d = 0;

  public static int getPoiPageCapacity()
  {
    return b;
  }

  public static void setPoiPageCapacity(int paramInt)
  {
    if ((paramInt > 0) && (paramInt <= 50))
      b = paramInt;
  }

  public int drivingSearch(String paramString1, MKPlanNode paramMKPlanNode1, String paramString2, MKPlanNode paramMKPlanNode2)
  {
    int i;
    int j;
    if ((paramMKPlanNode1 == null) || (paramMKPlanNode2 == null))
    {
      i = -1;
      return i;
    }
    if (this.a == null)
    {
      this.a = new Bundle();
      this.a.putInt("act", 11020203);
      this.a.putInt("opt", 11020102);
      if (paramMKPlanNode1.pt == null)
        break label468;
      this.a.putInt("start_x", paramMKPlanNode1.pt.getLongitudeE6());
      this.a.putInt("start_y", paramMKPlanNode1.pt.getLatitudeE6());
      j = 1;
      if ((paramMKPlanNode1.name != null) && (paramMKPlanNode1.name.length() <= 99));
    }
    try
    {
      this.a.putByteArray("start_name", paramMKPlanNode1.name.getBytes("gb2312"));
      label426: label468: label243: if ((paramString1 != null) && (paramString1.length() <= 31));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException3)
    {
      try
      {
        while (true)
        {
          while (true)
          {
            this.a.putByteArray("start_city", paramString1.getBytes("gb2312"));
            j = 1;
            if (j != 0)
              break label243;
            i = -1;
          }
          this.a.clear();
        }
        localUnsupportedEncodingException3 = localUnsupportedEncodingException3;
        Log.d("MKSearch drivingSearch:", "translate start name error!!");
        Log.d("MKSearch drivingSearch:", localUnsupportedEncodingException3.getMessage());
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException4)
      {
        int k;
        while (true)
        {
          while (true)
          {
            Log.d("MKSearch drivingSearch:", "translate start city error!!");
            Log.d("MKSearch drivingSearch:", localUnsupportedEncodingException4.getMessage());
          }
          i = -1;
        }
        if (paramMKPlanNode2.pt != null)
        {
          this.a.putInt("end_x", paramMKPlanNode2.pt.getLongitudeE6());
          this.a.putInt("end_y", paramMKPlanNode2.pt.getLatitudeE6());
          k = 1;
          if ((paramMKPlanNode2.name != null) && (paramMKPlanNode2.name.length() <= 99));
        }
        try
        {
          this.a.putByteArray("end_name", paramMKPlanNode2.name.getBytes("gb2312"));
          if ((paramString2 != null) && (paramString2.length() <= 31));
        }
        catch (UnsupportedEncodingException localUnsupportedEncodingException1)
        {
          try
          {
            while (true)
            {
              this.a.putByteArray("end_city", paramString2.getBytes("gb2312"));
              k = 1;
              if (k != 0)
                break label426;
              i = -1;
            }
            localUnsupportedEncodingException1 = localUnsupportedEncodingException1;
            Log.d("MKSearch drivingSearch:", "translate end name error!!");
            Log.d("MKSearch drivingSearch:", localUnsupportedEncodingException1.getMessage());
          }
          catch (UnsupportedEncodingException localUnsupportedEncodingException2)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        Log.d("MKSearch drivingSearch:", "translate end city error!!");
                        Log.d("MKSearch drivingSearch:", localUnsupportedEncodingException2.getMessage());
                      }
                      i = -1;
                    }
                    this.a.putInt("policy", this.d);
                    if (Mj.sendBundle(this.a) != 0)
                      break;
                    i = -1;
                  }
                  i = 0;
                }
                k = 0;
              }
              j = 0;
            }
          }
        }
      }
    }
  }

  public int goToPoiPage(int paramInt)
  {
    int i;
    if ((this.a == null) || (!(this.a.containsKey("page_num"))))
      i = -1;
    while (true)
    {
      while (true)
      {
        return i;
        this.a.putInt("cnt", b);
        this.a.putInt("page_num", paramInt);
        if (Mj.sendBundle(this.a) != 0)
          break;
        i = -1;
      }
      i = 0;
    }
  }

  public boolean init(BMapManager paramBMapManager, MKSearchListener paramMKSearchListener)
  {
    int i;
    if (paramBMapManager == null)
      i = 0;
    while (true)
    {
      while (true)
      {
        return i;
        if (paramMKSearchListener != null)
          paramBMapManager.a.a(paramMKSearchListener);
        if (Mj.initSearchCC() != 1)
          break;
        i = 1;
      }
      i = 1;
    }
  }

  public int poiMultiSearchInbounds(String[] paramArrayOfString, GeoPoint paramGeoPoint1, GeoPoint paramGeoPoint2)
  {
    int i;
    if ((paramArrayOfString == null) || (paramGeoPoint1 == null) || (paramGeoPoint2 == null))
      i = -1;
    while (true)
    {
      while (true)
      {
        StringBuilder localStringBuilder;
        while (true)
        {
          int j;
          while (true)
          {
            return i;
            if ((paramArrayOfString.length >= 2) && (paramArrayOfString.length <= 10))
              break;
            i = -1;
          }
          if (this.a == null)
          {
            this.a = new Bundle();
            localStringBuilder = new StringBuilder();
            j = 0;
          }
          while (true)
          {
            label100: String str;
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  if (j >= paramArrayOfString.length)
                    break label175;
                  if (paramArrayOfString[j] != null)
                    break label100;
                  i = -1;
                }
                this.a.clear();
              }
              str = paramArrayOfString[j].trim();
              if ((str.length() != 0) && (str.length() <= 99) && (!(str.contains("$$"))))
                break;
              i = -1;
            }
            localStringBuilder.append(str);
            if (j != paramArrayOfString.length - 1)
              localStringBuilder.append("$$");
            ++j;
          }
          label175: if (localStringBuilder.toString().length() <= 99)
            break;
          i = -1;
        }
        this.a.putInt("act", 11010203);
        this.a.putInt("opt", 11010111);
        this.a.putString("key", localStringBuilder.toString());
        this.a.putInt("page_num", 0);
        this.a.putInt("cnt", b);
        this.a.putInt("start_x", paramGeoPoint1.getLongitudeE6());
        this.a.putInt("start_y", paramGeoPoint1.getLatitudeE6());
        this.a.putInt("end_x", paramGeoPoint2.getLongitudeE6());
        this.a.putInt("end_y", paramGeoPoint2.getLatitudeE6());
        this.a.putInt("key_num", paramArrayOfString.length);
        if (Mj.sendBundle(this.a) != 0)
          break;
        i = -1;
      }
      i = 0;
    }
  }

  public int poiMultiSearchNearBy(String[] paramArrayOfString, GeoPoint paramGeoPoint, int paramInt)
  {
    int i;
    if ((paramGeoPoint == null) || (paramArrayOfString == null))
      i = -1;
    while (true)
    {
      while (true)
      {
        StringBuilder localStringBuilder;
        while (true)
        {
          int j;
          while (true)
          {
            while (true)
            {
              return i;
              if (paramInt > 0)
                break;
              i = -1;
            }
            if ((paramArrayOfString.length >= 2) && (paramArrayOfString.length <= 10))
              break;
            i = -1;
          }
          if (this.a == null)
          {
            this.a = new Bundle();
            localStringBuilder = new StringBuilder();
            j = 0;
          }
          while (true)
          {
            label107: String str;
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  if (j >= paramArrayOfString.length)
                    break label184;
                  if (paramArrayOfString[j] != null)
                    break label107;
                  i = -1;
                }
                this.a.clear();
              }
              str = paramArrayOfString[j].trim();
              if ((str.length() != 0) && (str.length() <= 99) && (!(paramArrayOfString[j].contains("$$"))))
                break;
              i = -1;
            }
            localStringBuilder.append(str);
            if (j != paramArrayOfString.length - 1)
              localStringBuilder.append("$$");
            ++j;
          }
          label184: if (localStringBuilder.toString().length() <= 99)
            break;
          i = -1;
        }
        this.a.putInt("act", 11010203);
        this.a.putInt("opt", 11010111);
        this.a.putString("key", localStringBuilder.toString());
        this.a.putInt("start_x", paramGeoPoint.getLongitudeE6());
        this.a.putInt("start_y", paramGeoPoint.getLatitudeE6());
        this.a.putInt("radius", paramInt);
        this.a.putInt("page_num", 0);
        this.a.putInt("cnt", b);
        this.a.putInt("key_num", paramArrayOfString.length);
        if (Mj.sendBundle(this.a) != 0)
          break;
        i = -1;
      }
      i = 0;
    }
  }

  public int poiSearchInCity(String paramString1, String paramString2)
  {
    String str1;
    String str2;
    String str3;
    int i;
    if (paramString2 == null)
      i = -1;
    while (true)
    {
      while (true)
      {
        return i;
        if (paramString1 != null)
          break label218;
        str1 = "";
        str2 = str1.trim();
        str3 = paramString2.trim();
        if (str2.length() <= 31)
          break;
        i = -1;
      }
      if ((str3.length() != 0) && (str3.length() <= 99))
        break;
      i = -1;
    }
    if (this.a == null)
    {
      this.a = new Bundle();
      this.a.putInt("act", 11010203);
      this.a.putInt("opt", 11010101);
    }
    try
    {
      while (true)
      {
        this.a.putByteArray("city", str2.getBytes("gb2312"));
        this.a.putString("key", str3);
        this.a.putInt("page_num", 0);
        this.a.putInt("cnt", b);
        if (Mj.sendBundle(this.a) != 0)
          break label212;
        i = -1;
      }
      label212: label218: this.a.clear();
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            Log.d("MKSearch poiSearchInCity:", "translate city error!!");
            Log.d("MKSearch poiSearchInCity:", localUnsupportedEncodingException.getMessage());
          }
          i = 0;
        }
        str1 = paramString1;
      }
    }
  }

  public int poiSearchInbounds(String paramString, GeoPoint paramGeoPoint1, GeoPoint paramGeoPoint2)
  {
    int i;
    if ((paramString == null) || (paramGeoPoint1 == null) || (paramGeoPoint2 == null))
      i = -1;
    while (true)
    {
      String str;
      while (true)
      {
        return i;
        str = paramString.trim();
        if ((str.length() != 0) && (str.length() <= 99))
          break;
        i = -1;
      }
      if (this.a == null)
        this.a = new Bundle();
      while (true)
      {
        while (true)
        {
          this.a.putInt("act", 11010203);
          this.a.putInt("opt", 11010104);
          this.a.putString("key", str);
          this.a.putInt("page_num", 0);
          this.a.putInt("cnt", b);
          this.a.putInt("start_x", paramGeoPoint1.getLongitudeE6());
          this.a.putInt("start_y", paramGeoPoint1.getLatitudeE6());
          this.a.putInt("end_x", paramGeoPoint2.getLongitudeE6());
          this.a.putInt("end_y", paramGeoPoint2.getLatitudeE6());
          if (Mj.sendBundle(this.a) != 0)
            break label202;
          i = -1;
        }
        this.a.clear();
      }
      label202: i = 0;
    }
  }

  public int poiSearchNearBy(String paramString, GeoPoint paramGeoPoint, int paramInt)
  {
    int i;
    if ((paramGeoPoint == null) || (paramString == null))
      i = -1;
    while (true)
    {
      String str;
      while (true)
      {
        while (true)
        {
          return i;
          if (paramInt > 0)
            break;
          i = -1;
        }
        str = paramString.trim();
        if ((str.length() != 0) && (str.length() <= 99))
          break;
        i = -1;
      }
      if (this.a == null)
        this.a = new Bundle();
      while (true)
      {
        while (true)
        {
          this.a.putInt("act", 11010203);
          this.a.putInt("opt", 11010104);
          this.a.putString("key", str);
          this.a.putInt("start_x", paramGeoPoint.getLongitudeE6());
          this.a.putInt("start_y", paramGeoPoint.getLatitudeE6());
          this.a.putInt("radius", paramInt);
          this.a.putInt("page_num", 0);
          this.a.putInt("cnt", b);
          if (Mj.sendBundle(this.a) != 0)
            break label193;
          i = -1;
        }
        this.a.clear();
      }
      label193: i = 0;
    }
  }

  public int reverseGeocode(GeoPoint paramGeoPoint)
  {
    int i;
    if (paramGeoPoint == null)
      i = -1;
    while (true)
    {
      return i;
      if (this.a == null)
        this.a = new Bundle();
      while (true)
      {
        while (true)
        {
          this.a.putInt("act", 11010203);
          this.a.putInt("opt", 11010109);
          this.a.putInt("x", paramGeoPoint.getLongitudeE6());
          this.a.putInt("y", paramGeoPoint.getLatitudeE6());
          if (Mj.sendBundle(this.a) != 0)
            break label101;
          i = -1;
        }
        this.a.clear();
      }
      label101: i = 0;
    }
  }

  public int setDrivingPolicy(int paramInt)
  {
    int i;
    if ((paramInt > 2) || (paramInt < 0))
      i = -1;
    while (true)
    {
      return i;
      this.d = paramInt;
      i = 0;
    }
  }

  public int setTransitPolicy(int paramInt)
  {
    int i;
    if ((paramInt > 6) || (paramInt < 3))
      i = -1;
    while (true)
    {
      return i;
      this.c = paramInt;
      i = 0;
    }
  }

  public int transitSearch(String paramString, MKPlanNode paramMKPlanNode1, MKPlanNode paramMKPlanNode2)
  {
    int i;
    int j;
    if ((paramString == null) || (paramMKPlanNode1 == null) || (paramMKPlanNode2 == null))
      i = -1;
    while (true)
    {
      return i;
      if (paramString.length() <= 31)
        break;
      i = -1;
    }
    if (this.a == null)
    {
      this.a = new Bundle();
      this.a.putInt("act", 11020203);
      this.a.putInt("opt", 11020101);
    }
    try
    {
      this.a.putByteArray("city", paramString.getBytes("gb2312"));
      if (paramMKPlanNode1.pt != null)
      {
        this.a.putInt("start_x", paramMKPlanNode1.pt.getLongitudeE6());
        this.a.putInt("start_y", paramMKPlanNode1.pt.getLatitudeE6());
        j = 1;
        label242: if ((paramMKPlanNode1.name != null) && (paramMKPlanNode1.name.length() <= 99));
      }
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException1)
    {
      try
      {
        while (true)
        {
          while (true)
          {
            this.a.putByteArray("start_name", paramMKPlanNode1.name.getBytes("gb2312"));
            j = 1;
            if (j != 0)
              break label242;
            i = -1;
          }
          this.a.clear();
        }
        localUnsupportedEncodingException1 = localUnsupportedEncodingException1;
        Log.d("MKSearch transitSearch:", "translate city error!!");
        Log.d("MKSearch transitSearch:", localUnsupportedEncodingException1.getMessage());
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException3)
      {
        int k;
        while (true)
        {
          Log.d("MKSearch transitSearch:", "translate start name error!!");
          Log.d("MKSearch transitSearch:", localUnsupportedEncodingException3.getMessage());
        }
        if (paramMKPlanNode2.pt != null)
        {
          this.a.putInt("end_x", paramMKPlanNode2.pt.getLongitudeE6());
          this.a.putInt("end_y", paramMKPlanNode2.pt.getLatitudeE6());
          k = 1;
          if ((paramMKPlanNode2.name != null) && (paramMKPlanNode2.name.length() <= 99));
        }
        try
        {
          this.a.putByteArray("end_name", paramMKPlanNode2.name.getBytes("gb2312"));
          k = 1;
          if (k == 0)
            i = -1;
        }
        catch (UnsupportedEncodingException localUnsupportedEncodingException2)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    Log.d("MKSearch transitSearch:", "translate end name error!!");
                    Log.d("MKSearch transitSearch:", localUnsupportedEncodingException2.getMessage());
                  }
                  this.a.putInt("policy", this.c);
                  if (Mj.sendBundle(this.a) != 0)
                    break;
                  i = -1;
                }
                i = 0;
              }
              k = 0;
            }
            j = 0;
          }
        }
      }
    }
  }

  public int walkingSearch(String paramString1, MKPlanNode paramMKPlanNode1, String paramString2, MKPlanNode paramMKPlanNode2)
  {
    int i;
    int j;
    if ((paramMKPlanNode1 == null) || (paramMKPlanNode2 == null))
    {
      i = -1;
      return i;
    }
    if (this.a == null)
    {
      this.a = new Bundle();
      this.a.putInt("act", 11020203);
      this.a.putInt("opt", 11020103);
      if (paramMKPlanNode1.pt == null)
        break label455;
      this.a.putInt("start_x", paramMKPlanNode1.pt.getLongitudeE6());
      this.a.putInt("start_y", paramMKPlanNode1.pt.getLatitudeE6());
      j = 1;
      if ((paramMKPlanNode1.name != null) && (paramMKPlanNode1.name.length() <= 99));
    }
    try
    {
      this.a.putByteArray("start_name", paramMKPlanNode1.name.getBytes("gb2312"));
      label426: label455: label243: if ((paramString1 != null) && (paramString1.length() <= 31));
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException3)
    {
      try
      {
        while (true)
        {
          while (true)
          {
            this.a.putByteArray("start_city", paramString1.getBytes("gb2312"));
            j = 1;
            if (j != 0)
              break label243;
            i = -1;
          }
          this.a.clear();
        }
        localUnsupportedEncodingException3 = localUnsupportedEncodingException3;
        Log.d("MKSearch walkingSearch:", "translate start name error!!");
        Log.d("MKSearch walkingSearch:", localUnsupportedEncodingException3.getMessage());
      }
      catch (UnsupportedEncodingException localUnsupportedEncodingException4)
      {
        int k;
        while (true)
        {
          while (true)
          {
            Log.d("MKSearch walkingSearch:", "translate start city error!!");
            Log.d("MKSearch walkingSearch:", localUnsupportedEncodingException4.getMessage());
          }
          i = -1;
        }
        if (paramMKPlanNode2.pt != null)
        {
          this.a.putInt("end_x", paramMKPlanNode2.pt.getLongitudeE6());
          this.a.putInt("end_y", paramMKPlanNode2.pt.getLatitudeE6());
          k = 1;
          if ((paramMKPlanNode2.name != null) && (paramMKPlanNode2.name.length() <= 99));
        }
        try
        {
          this.a.putByteArray("end_name", paramMKPlanNode2.name.getBytes("gb2312"));
          if ((paramString2 != null) && (paramString2.length() <= 31));
        }
        catch (UnsupportedEncodingException localUnsupportedEncodingException1)
        {
          try
          {
            while (true)
            {
              this.a.putByteArray("end_city", paramString2.getBytes("gb2312"));
              k = 1;
              if (k != 0)
                break label426;
              i = -1;
            }
            localUnsupportedEncodingException1 = localUnsupportedEncodingException1;
            Log.d("MKSearch walkingSearch:", "translate end name error!!");
            Log.d("MKSearch walkingSearch:", localUnsupportedEncodingException1.getMessage());
          }
          catch (UnsupportedEncodingException localUnsupportedEncodingException2)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        Log.d("MKSearch walkingSearch:", "translate end city error!!");
                        Log.d("MKSearch walkingSearch:", localUnsupportedEncodingException2.getMessage());
                      }
                      i = -1;
                    }
                    if (Mj.sendBundle(this.a) != 0)
                      break;
                    i = -1;
                  }
                  i = 0;
                }
                k = 0;
              }
              j = 0;
            }
          }
        }
      }
    }
  }
}